# Maintainer: Geoffroy Carrier <geoffroy.carrier@aur.archlinux.org>
# Previous Maintainer: Jason Chu <jason@archlinux.org>
pkgname=jdk
pkgver=5.0u21
pkgrel=1
pkgdesc="Sun's Java Development Kit"
#arch=(i686 x86_64)
arch=(i686)
  [ "${CARCH}" = "i686" ]   && ARCH=i586
  #[ "${CARCH}" = "x86_64" ] && ARCH=amd64
url="http://java.sun.com"
depends=('glibc' 'jre')
install="jdk.install"
source=(http://download.java.net/dlj/binaries/jdk-${pkgver}-dlj-linux-${ARCH}.bin
        https://jdk-distros.dev.java.net/source/browse/*checkout*/jdk-distros/trunk/utils/construct.sh
	jdk.profile)
[ "$CARCH" = "i686" ]   && md5sums=('0c9c81f8f0b85fd96a8db06d36b50b33'
			           '94065b612df0046d9ae758943f9f6a75'
				   '7aaac9ec3e440b92361c6561ac00424a')
#[ "$CARCH" = "x86_64" ] && md5sums=('92c45c9304ac3bc3103883f61b1f49df'
			            #'94065b612df0046d9ae758943f9f6a75'
	          		    #'7aaac9ec3e440b92361c6561ac00424a')
replaces=('j2sdk')
conflicts=('java-environment' 'j2sdk')
provides=('java-environment=6' 'j2sdk')
license=('custom')

build() {
  cd ${startdir}/src

  mkdir unbundle-jdk
  cd unbundle-jdk

  sh ../jdk-${pkgver}-dlj-linux-${ARCH}.bin --accept-license

  cd ..

  sh construct.sh unbundle-jdk linux-jdk linux-jre

  #copy icon
  install -Dm644 $srcdir/linux-jdk/jre/lib/desktop/icons/hicolor/48x48/apps/sun-java.png $pkgdir/usr/share/pixmaps/java.png

  rm -rf linux-jdk/jre

  mkdir -p ${startdir}/pkg/opt
  mv linux-jdk ${startdir}/pkg/opt/java

  install -D -m755 ${startdir}/src/${pkgname}.profile ${startdir}/pkg/etc/profile.d/${pkgname}.sh

  mkdir -p $startdir/pkg/usr/share/licenses/jdk
  cp $startdir/pkg/opt/java/COPYRIGHT $startdir/pkg/usr/share/licenses/jdk
  cp $startdir/pkg/opt/java/LICENSE $startdir/pkg/usr/share/licenses/jdk
  cp $startdir/pkg/opt/java/THIRDPARTYLICENSEREADME.txt $startdir/pkg/usr/share/licenses/jdk

  #desktop entries
  install -Dm644 $startdir/java-control-panel.desktop ${pkgdir}/usr/share/applications/java-control-panel.desktop
  install -Dm644 $startdir/java-monitoring-and-management-console.desktop  ${pkgdir}/usr/share/applications/java-monitoring-and-management-console.desktop
  install -Dm644 $startdir/java-policy-settings.desktop ${pkgdir}/usr/share/applications/java-policy-settings.desktop
  install -Dm644 $startdir/java-visualvm.desktop ${pkgdir}/usr/share/applications/java-visualvm.desktop
  install -Dm644 $startdir/java-web-start.desktop ${pkgdir}/usr/share/applications/java-web-start.desktop
}
md5sums=('36f1628264efaaebf70812cdafb27a52'
         '94065b612df0046d9ae758943f9f6a75'
         '7aaac9ec3e440b92361c6561ac00424a')
